<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
	language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<h2>Danh sách sân bóng đã đặt</h2>
<div class="list-table">
	
	<form method="post" action="" id="form" name="form" >
	<table id="ver-zebra">
		<colgroup>
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
		</colgroup>
		<thead>
			<tr>
				<th scope="col" id="vzebra-adventure">OrderNo </th>
				<th scope="col" id="vzebra-adventure">Tên sân</th>
				<th scope="col" id="vzebra-adventure">Sân</th>
				<th scope="col" id="vzebra-adventure">Địa chỉ</th>
				<th scope="col" id="vzebra-adventure">Khung giờ</th>
				<th scope="col" id="vzebra-adventure">Bảng giá</th>
				<th scope="col" id="vzebra-adventure">Từ ngày</th>
				<th scope="col" id="vzebra-adventure">Đến ngày</th>
				<th scope="col" id="vzebra-adventure">Đặt cọc</th>
				<th scope="col" id="vzebra-adventure">Hủy</th>
			<!-- 	<th scope="col" id="vzebra-adventure">Chi tiết</th> -->
			</tr>
		</thead>
		<tbody>
			<s:if test="%{listSoccerOrder.isEmpty()}">
				<tr>
					<td colspan="12">Chưa có dữ liệu</td>
				</tr>
			</s:if>
			<s:else>
				<s:iterator value="listSoccerOrder">
					<tr>
						<%-- <td><input type="radio" name="select" id="select"
							onchange="$('#error_message').css('display','none');$('#form').validate().resetForm();"
							onfocus="setSoccerField('<s:property value="id"/>','<s:property value="name" />','<s:property value="image_url" />','<s:property value="district" />','<s:property value="address"/>',
							'<s:property value="listTimeDivision[0].period"/>','<s:property value="getPrice(listTimeDivision[0].price)"/>',
							'<s:property value="listTimeDivision[1].period"/>','<s:property value="getPrice(listTimeDivision[1].price)"/>',
							'<s:property value="listTimeDivision[2].period"/>','<s:property value="getPrice(listTimeDivision[2].price)"/>',
							'<s:property value="listTimeDivision[3].period"/>','<s:property value="getPrice(listTimeDivision[3].price)"/>',
							'<s:property value="listTimeDivision[4].period"/>','<s:property value="getPrice(listTimeDivision[4].price)"/>',
							'<s:property value="description"/>')" /></td> --%>
						<td><s:property value="orderNo" /></td>	
						<td><s:property value="timeDivision.soccerField.name" /></td>
						<td><s:property value="timeDivision.subSoccerField" /></td>
						<td><s:property value="timeDivision.soccerField.address" /></td>
						<td><s:property value="timeDivision.period" /></td>
						<td><s:property value="getPriceFormat(timeDivision.price)" /></td>
						<td><s:property value="getFormatDate(startDate)" /></td>
						<td><s:property value="getFormatDate(endDate)" /></td>
						<td><s:property value="deposits" /></td>
						<s:if test="%{status == false}">
							<td>Đã hủy</td>
						</s:if>
						<s:else>
							<s:if test="checkResetOrder(endDate)">
								<td><input type="button" value="Hủy" onclick="deleteSoccerOrder(<s:property value='id' />)"/></td>
							</s:if>
							<s:else>
								<td>Không thể hủy</td>
							</s:else>
						</s:else>
						<%-- <td><input type="button" value="Chi tiết" onclick="detailSoccerOrder(<s:property value='id' />)"/></td> --%>
					  </tr>
				</s:iterator>
			</s:else>
		</tbody>
	</table>
	</form>
</div>

<script type="text/javascript">


	function deleteSoccerOrder(id) {
		var datastr = 'id=' + id;
			$.ajax({
				type : "POST",
				url : 'deleteSoccerOrder',
				data : datastr,
				cache : false,
				dataType : 'text',
				beforeSend : function() {
					$.blockUI({
						css : {
							border : 'none',
							padding : '15px',
							backgroundColor : '#000',
							'-webkit-border-radius' : '10px',
							'-moz-border-radius' : '10px',
							opacity : .5,
							color : '#fff'
						}
					});
				},
				complete : function() {
					$.unblockUI();
				},
				success : function(html) {
					goBack();
				},
				error : function(err) {
					$('#error_message').html("Thất bại");
					$('#error_message').css("display", "block");
				}
			});
	}


	
	function goBack() {
		var url = "getListSoccerOrder";
		window.location.href = url;
	}
	
</script>
